import java.util.Scanner;
import java.io.*;

public class Questions {
    public static void main(String[] args) throws FileNotFoundException {
    //OutputQuestionsToFile(){
        Scanner scan = new Scanner(System.in);
    MakeQuestions Nq = new MakeQuestions();
    //IOFile iof = new IOFile("Exercises.txt");
    PrintStream ps = new PrintStream("Exercises.txt");;

    int count, level;
    int q = 0;
    String expr;

   //public void oq() throws IOException {
    while(true)

    {
        System.out.print("请输入要生成的题目数：");
        count = scan.nextInt();
        System.out.print("请输入生成题目的级别（每增加一级多一个运算符，最低为一级）：");
        level = scan.nextInt();
        System.out.println(" ");
        if (count > 0 && level > 0) {
            for (int i = 0; i < count; i++) {
                //生成题目
                int a;
                a = i + 1;
                expr = Nq.getExper(level);
                String s = "题目" + a + ":" + expr + " =\n";
                System.out.println(s);
               //iof.WriteQuestionsToFile(s);
                ps.append(s);
            }
            break;
        } else {
            System.out.println("题目数和题目等级必须大于零!");
        }
        //iof.close();
        //ps.close();
    }
    Process p=null;
    try {
            p=Runtime.getRuntime().exec("notepad.exe Exercises.txt");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}